package com.geeksaga.dao.ibatis.mysql;

import java.util.List;


import org.springframework.dao.DataAccessException;
import org.springframework.stereotype.Repository;

import com.geeksaga.common.util.DateConvertor;
import com.geeksaga.dao.CounterDao;
import com.geeksaga.dao.ibatis.BaseIBatisDao;
import com.geeksaga.domain.Counter;

/**
 * @author newbie
 * @since 0.1
 */
@Repository
public class CounterDaoImpl extends BaseIBatisDao implements CounterDao {

    /* (non-Javadoc)
     * @see com.geeksaga.dao.CounterDao#add(com.geeksaga.domain.Counter)
     */
    public CounterDao add(Counter counter) throws DataAccessException {
    	counter.setRegistDate(DateConvertor.getDateFormat());
    	counter.setRegistTime(DateConvertor.getTimeFormat());
		
        return (CounterDao) getSqlMapClientTemplate().insert("COUNTER.add", counter);
    }

    /* (non-Javadoc)
     * @see com.geeksaga.dao.CounterDao#list()
     */
    @SuppressWarnings("unchecked")
    public List<Counter> list() throws DataAccessException {
        return (List<Counter>) getSqlMapClientTemplate().queryForList("COUNTER.list");
    }
}